$(function () {
  $.ajax({
    url: "../lib/goods.json",
    type: "get",
    dataType: "json",
    success: function (data) {
      const obj = parseQueryString(window.location.search);
      if (!obj.goodsId) return (window.location.href = "./list.html");

      
      const goodsId = obj.goodsId;
      const goodsImg = data[goodsId - 1].image;
      const goodsPrice = data[goodsId - 1].price
      const goodsName = data[goodsId - 1].title


      $('.right > .desc').html(goodsName)
      $('.right > .price').html("价格：" + goodsPrice)
      $(".left > .img1 > img").attr({src: goodsImg , "title": goodsName});
      $(".left > .list > .active")
        .append("<img/>")
        .children()
        .attr({ src: goodsImg, "data-show": goodsImg, "data-big": goodsImg ,"title": goodsName});
      $(".left > .enlarge").css("background-image", "url(" + goodsImg + ")");
      new Enlarge(".left");
      $("button").first().on('click' , function(){
        location.href = "./shop.html"
      })
      $("button").last().on('click' , function(){
        location.href = "./list.html"
      })
    },
  });
});
